package com.coder.oj.admin.config;

import com.coder.oj.common.config.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    /**
     * 注册拦截器
     * @author Bosen 2022/11/29 21:47
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 登录拦截
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("/**");
        // 权限拦截
        registry.addInterceptor(new RbacHandlerInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/v2/api-docs/**",
                        "/swagger-ui.html",
                        "/doc.html",
                        "/swagger-resources/**",
                        "/webjars/**",
                        "/login/**",
                        "/file/**"
                );
    }
}
